<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
 * Description of admin_model
 *
 * @author Giovani
 */
class AdminModel extends CI_Model {

    function __construct(){
        parent::__construct();
    }

    public function inserir($dados){
        $this->db->insert("admin", $dados);
        return $this->db->insert_id();
    }

    public function update($id, $dados){
        $this->db->where("idAdmin", $id);
        $this->db->update("admin", $dados);
    }

    public function delete($id){
        $this->db->where("idAdmin", $id);
        $this->db->delete("admin");
    }

    public function getAdmin($id){
        $this->db->from("admin");
        $this->db->where("idAdmin", $id);
        $query = $this->db->get();

        if( $query->num_rows() > 0 ) :
            return $query->row(0);

        else :
            return false;

        endif;
    }

    public function listar(){
        $query = $this->db->get("admin");
        return $query;
    }

    public function getAdminEmail($email){
        $this->db->where("email", $email);
        $this->db->from("admin");
        $query = $this->db->get();

        if( $query->num_rows() > 0 ) :
            return $query->row(0);
        
        else :
            return false;

        endif;
    }
   
}
